package com.ruoyi.project.port.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.port.domain.*;
import com.ruoyi.project.port.service.PortService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLOutput;

@Api(value = "jiekou ")
@Controller
@RequestMapping("/api")
public class PortController {

    @Autowired
    private PortService portService;

    @GetMapping("/index")
    public String basCustomer() {
        return "rf/welcome_out";
    }

    /**
     * @Description: 基础信息物料<br />
     * @author: zyr <br/>
     * @date: 2023/8/23 9:09 <br/>
     */
//    @RequestMapping("/basMaterialInfo")
//    @ResponseBody
//    public Result productMsg(@RequestBody ProductMsg productMsg) {
//
//        Result result = portService.insertProduct(productMsg);
//        return result;
//    }

    /**
     * @Description: 基础信息客户 <br/>
     * @author: zyr <br/>
     * @date: 2023/8/23 9:09 <br/>
     */
//    @RequestMapping("/customerInfo")
//    @ResponseBody
//    public Result customerMsg(@RequestBody CustomerMsg customerMsg) {
//        Result result = portService.insertCustomer(customerMsg);
//        return result;
//
//    }

    /**
     * @Description: 基础信息供应商 <br/>
     * @author: zyr <br/>
     * @date: 2023/8/23 9:09 <br/>
     */

//    @RequestMapping("/supplierInfo")
//    @ResponseBody
//    public Result supplierMsg(@RequestBody SupplierMsg supplierMsg) {
//        Result result = portService.insertSupplier(supplierMsg);
//        return result;
//    }

    /**
     * @Description: 入库单下发<br />
     * @author: zyr <br/>
     * @date: 2023/8/23 11:29 <br/>
     */
    @ApiOperation("入库单下发")
    @RequestMapping("/inOrder")
    @ResponseBody
    public Result getInOrder(@RequestBody InOrderMsg inOrderMsg) {
        Result result = portService.insertInOrder(inOrderMsg);
        return result;

    }

    /**
     * @Description: 出库单下发 <br/>
     * @author: zyr <br/>
     * @date: 2023/8/23 16:41 <br/>
     */
    @RequestMapping("/outOrder")
    @ResponseBody
    public Result getOutOrder(@RequestBody OutOrderMsg outOrderMsg) {
        Result result = portService.insertOutOrder(outOrderMsg);
        return result;
    }

    /**
     * @Description: 暂存单入库<br />
     * @author: zyr <br/>
     * @date: 2023/8/24 15:12 <br/>
     */
    @RequestMapping("/depositOrder")
    @ResponseBody
    public Result getDepositOrder(@RequestBody DepositOrderMsg depositOrderMsg) {
        Result result = new Result();
        if (StringUtils.isEmpty(depositOrderMsg.getOrderId())) {
            result.setCode(1);
            result.setMsg("订单号不能为空");
        }
        if (depositOrderMsg.getOrderType() == null) {
            result.setCode(1);
            result.setMsg("订单类型不能为空");
        }


        if (depositOrderMsg.getOrderType() == 1) {
            result = portService.insertDepositInOrder(depositOrderMsg);
        } else {
            result = portService.insertDepositOutOrder(depositOrderMsg);
        }
        return result;
    }


    /**
     * @Description: 库存查询<br />
     * @author: 祁雪琼 <br/>
     * @date: 2023/11/10 15:12 <br/>
     */
    /*@RequestMapping("/inventoryInfo")
    @ResponseBody
    public InventoryRespond getInventoryInfo(@RequestBody InventoryRequest inventoryRequest) {
        InventoryRespond inventoryInfo = portService.getInventoryInfo(inventoryRequest);
        return inventoryInfo;
    }*/

    /**
    * @Description: 物品资料对应关系<br/>
    * @author: zyr <br/>
    * @date: 2024/1/26 10:31 <br/>
    */
    @RequestMapping("/productMap")
    @ResponseBody
    public Result getProductMap(@RequestBody ProductMapMsg productMapMsg){
        Result result=portService.getProductMap(productMapMsg);
        return result;
    }


//    /**
//    * @Description: 入库单回传接收测试 <br/>
//    * @author: zyr <br/>
//    * @date: 2023/8/25 10:14 <br/>
//    */
//    @RequestMapping("/backInOrdertest")
//    @ResponseBody
//    public void backInOrdertest(BackInOrder backInOrder){
//        System.out.println(backInOrder);
//
//    }


}
